<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
    <script src="../vue-v2.3.2.js"></script>
    <!--<script src="vue-resource.js"></script>-->
    <script src="../vue-resource-v1.3.3.js"></script>
    <style>
        .red_color{
            color:red;
        }
        .bg_blue{
            background-color: blue;
        }
    </style>
    <script>
        window.onload=function(){
            var vm=new Vue({
                el:"#box",
                data:{

                },
                methods:{
                    get:function(){
                        this.$http.get('a.txt').then(function(res){
                            console.log(res);
                            alert(res.data);
                        },function(err){
                            console.log(err);
                        });
                    },
                    send:function(){
                        this.$http.post('get.php',
                                {"a":1,"b":2},
                                {emulateJSON : true}
                        ).then(function(res){
                            console.log(res);
                            alert(res.data);
                        },function(err){
                            console.log(err);
                        });
                    },
                    send2:function(){
                        this.$http.get('./get.php',{
                            params:{"a":1,"b":2}
                        }
                        ).then(function(res){
                            console.log(res);
                            alert(res.data);
                        },function(err){
                            console.log(err);
                        });
                    },
                    send3:function(){
                        this.$http.jsonp('https://sug.so.360.cn/suggest',//?callback=suggest_so&word=a',
                                {
                                    params:{word:"a"},
                                    jsonp : "callback"
                                }
                        ).then(function(res){
                            console.log(res);
                            alert(res.data.s);
                        },function(err){
                            console.log(err);
                        });
                    },
                    send4:function(){
                        this.$http.jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su',//?wd=a&cb=jshow',
                                {
                                    params:{wd:"a"},
                                    jsonp : "cb"
                                }
                        ).then(function(res){
                            console.log(res);
                            alert(res.data.s);
                        },function(err){
                            console.log(err);
                        });
                    }
                }
            });
        };
    </script>
</head>
<body>
<div id="box">
    <input type="button" value="获取数据" @click="get();">
    <input type="button" value="post发送数据" @click="send();">
    <input type="button" value="get发送数据" @click="send2();">
    <input type="button" value="jsonp跨域360" @click="send3();">
    <input type="button" value="jsonp跨域百度" @click="send4();">
</div>
</body>
</html>